<template>
  <div class="app-container">
    <basic-table
      :table-title="typeValue === 3 ? tableTitle2 : tableTitle"
      :data-source="dataSource"
      :button-group="buttonGroup"
      :search-form="searchForm"
      :model-type="'dataVolumeStatistics'"
      :multiple-table="false"
      :reload="reload"
      @closeReload="closeReload"
      @watchTypeEmit2="watchTypeEmit2"
      >
      <template v-slot:IncrementRate="scope">
        <div style="color: #E6A23C">
        {{ scope.row.IncrementRate }}
        </div>
      </template>
      <template v-slot:CallIncrementRate="scope">
        <div style="color: #67C23A">
          {{ scope.row.CallIncrementRate }}
        </div>
      </template>
    </basic-table>
  </div>
</template>
<script>
import { getDataVolumeForms } from '@/api/report'
import BasicTable from '@/components/BasicTable/index.vue'
export default {
  name: 'DataVolumeStatistics',
  components: { BasicTable },
  data() {
    return {
      reload: false,
      dataSource: () => getDataVolumeForms,
      tableTitle: [
        {
          label: '月份',
          value: 'Month',
          show: true,
          type: 'text'
        },
        {
          label: '总量',
          value: 'Total',
          show: true,
          type: 'text'
        },
        {
          label: '增量',
          value: 'Increment',
          show: true,
          type: 'text'
        },
        {
          label: '环比',
          value: 'IncrementRate',
          show: true,
          type: 'slot',
          slot: 'IncrementRate'
        },
        {
          label: '带联系人总量',
          value: 'CallTotal',
          show: true,
          type: 'text'
        },
        {
          label: '带联系人增量',
          value: 'CallIncrement',
          show: true,
          type: 'text'
        },
        {
          label: '带联系人环比',
          value: 'CallIncrementRate',
          show: true,
          type: 'slot',
          slot: 'CallIncrementRate'
        },
      ],
      tableTitle2: [
        {
          label: '月份',
          value: 'Month',
          show: true,
          type: 'text'
        },
        {
          label: '总量',
          value: 'Total',
          show: true,
          type: 'text'
        },
        {
          label: '增量',
          value: 'Increment',
          show: true,
          type: 'text'
        },
        {
          label: '环比',
          value: 'IncrementRate',
          show: true,
          type: 'slot',
          slot: 'IncrementRate'
        }
      ],
      searchForm: {
        expend: true,
        title: '数据量统计',
        fields: [
          {
            show: true,
            type: 'select',
            label: '',
            labelShow: true,
            name: 'type',
            options: [
              {value: 1,label: '企业'},
              {value: 2,label: '人员'},
              {value: 3,label: '项目'}
            ]
          },
        ]
      },
      buttonGroup: {},
      typeValue: 1,
    }
  },
  created(){
   this.watchTypeEmit2()
  },
  methods: {
    watchTypeEmit2(v){
      this.typeValue = v
    },
    closeReload(val) {
      this.reload = val
    },
  }
}
</script>

<style scoped></style>
